﻿using System;

namespace Looptribe.Moodlin8.ViewModel
{
    public class MonthSelector
    {
        private readonly DateTime _date;

        public MonthSelector(DateTime date)
        {
            _date = date;
        }

        public DateTime Date { get { return _date; } }

        public override string ToString()
        {
            return Date.ToString("y");
        }

        protected bool Equals(MonthSelector other)
        {
            return _date.Year == other.Date.Year && _date.Month == other.Date.Month;
        }

        public override int GetHashCode()
        {
            return _date.Month | (_date.Year << 8);
        }

        public override bool Equals(object obj)
        {
            var other = obj as MonthSelector;
            if (other == null)
                return false;
            return Equals(other);
        }
    }
}
